home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / r / real_3d / real3dv3.3b.dms / real3dv3.3b.adf / GUI.LZH / GUI / simple.gui < prev    next >
Text File  |  1995-05-04  |  2KB  |  92 lines

  1.  
  2. (
  3. ( Very simple GUI example. This opens one window which contains only
  4. ( two buttons. 
  5.  
  6. ( Variables, words etc. must not be defined more than once. ?& SIMPLE_GUI
  7. ( attempts to fetch the address of SIMPLE_GUI constant. If cannot be found
  8. ( we know that the program is loaded for the first time.
  9.  
  10. ?& SIMPLE_GUI NOT ?IF 
  11.  
  12.  
  13. ( define SIMPLE_GUI to make sure that these will not be defined again later.
  14.  
  15. 1 CONSTANT SIMPLE_GUI
  16.  
  17.  
  18. ( this file contains necessary RPL definitions for GUI words.
  19.  
  20. "ui.rpl" LOAD
  21.  
  22.  
  23. ( Variables, make sure these are unique. Conflicts with other RPL gui
  24. ( programs can crash the system.
  25.  
  26. VARIABLE siaWindow
  27.  
  28.  
  29. ( Callbacks for buttons. When the user clicks buttons, these words 
  30. ( are called.
  31.  
  32. : sicbButton
  33.     "I See" "Button Clicked" GET_KEY DROP
  34. ;
  35.  
  36. : sicbHelp
  37.     "r3d3:help/simple_gui.guide" "main" 0 AGUIDE
  38. ;
  39.  
  40. : sicbClose
  41.     siaWindow FETCH UI_DELETE   ( delete the window
  42.     NULL siaWindow STORE         ( set siaWindow to NULL 
  43. ;
  44.  
  45.  
  46. ( Callback for Window. Mouse movements, mouse clicks and close window 
  47. ( events are reported.
  48.  
  49. : sicbWindow 
  50.     PARAM
  51.         VARIABLE iMouseY
  52.         VARIABLE iMouseX
  53.         VARIABLE iEvent
  54.     ENDPARAM
  55.  
  56.     ( Check if iEvent is equal to UIWM_Close
  57.     iEvent FETCH UIWM_Close = 
  58.     IF
  59.         siaWindow FETCH UI_DELETE    ( Close window
  60.         NULL siaWindow STORE         ( Set siaWindow to NULL 
  61.     ENDIF
  62. ;
  63.  
  64. ?ENDIF
  65.  
  66.  
  67. ( Now that we have defined all the required variables and words it is time 
  68. ( to create windows and other display elements. 
  69.  
  70. ( if window is already open, prompt proper error message and do nothing.
  71. siaWindow FETCH
  72. ?IF
  73.     "Understood" "Window already opened" GET_KEY DROP
  74. ?ELSE
  75.  
  76.     ( otherwise, open all display elements
  77.  
  78.     ( Open a window
  79.     UI_Done 
  80.     & sicbWindow 0 0 400 100 "Simple GUI Example" UI_WINDOW siaWindow STORE
  81.  
  82.     ( create button gadgets, no need to save handles
  83.     UI_Done siaWindow FETCH & sicbButton 20 50  80 12 "Button" UI_BUTTON DROP
  84.     UI_Done siaWindow FETCH & sicbHelp  100 50  80 12 "Help"   UI_BUTTON DROP
  85.     UI_Done siaWindow FETCH & sicbClose 220 50 130 12 "Close"  UI_BUTTON DROP
  86.     
  87.     ( realize display elements
  88.     siaWindow FETCH UI_REALIZE
  89.  
  90. ?ENDIF 
  91.